package com.wyp.demo.pattern.event;

/**
 * @author: Oliver
 * @time: 2020/12/11/21:52
 *
 * 测试事件监听
 */
public class EventTest {
    public static void main(String[] args) {
        //创建监听器
        EventListener d = new DoubleEventListener();
        EventListener s = new SingleEventListener();

        //创建事件
        Event event = new Event();
        event.setType("single");

        //创建事件源
        EventSource source = new EventSource();
        //将监听器注册到事件源中
        source.regist(s).regist(d);
//        发布事件
        source.publisher(event);
    }
}
